8,282 views
33 33 votes

Given a set of $n$ distinct numbers, we would like to determine both the smallest and the largest number. Which of the following statements is TRUE?

  1. These two elements can be determined using $O\left(\log^{100}n\right)$ comparisons.
  2. $O\left(\log^{100}n\right)$ comparisons do not suffice, however these two elements can be determined using $n + O(\log n)$ comparisons.
  3. $n+O(\log n)$ comparisons do not suffice, however these two elements can be determined using $3\lceil n/2 \rceil$ comparisons.
  4. $3\lceil n/2 \rceil$ comparisons do not suffice, however these two elements can be determined using $2(n - 1)$ comparisons.
  5. None of the above.

2 Answers

Best answer
18 18 votes

Answer will be C.

To be accurate, it will need $3n/2 -2$ comparisons .

• edited by
9 9 votes

Similar to the approach proposed by Himanshu1 here:

https://gateoverflow.in/27194/tifr2014-b-9

Construct a decision tree to determine the minimum element: $n - 1$ comparisons

Maximum element can be found from the same tree as it will be the biggest element out of $\frac{n}{2}$ elements at the first level which lost the decision: $\frac{n}{2} - 1$ comparisons

Therefore, the resultant number of comparisons: $3(\frac{n}{2}) - 2$, tighest bound on which is option (C).

Answer:
Position:
Show:

Related questions

61 61 votes
8 answers 8 answers
19.8k
19.8k views
Misbah Ghaya asked Nov 19, 2015
19,818 views
Given a set of $n$ distinct numbers, we would like to determine the smallest three numbers in this set using comparisons. Which of the following statements is TRUE?These ...
31 31 votes
3 answers 3 answers
5.2k
5.2k views
Misbah Ghaya asked Nov 19, 2015
5,195 views
Consider the problem of computing the minimum of a set of $n$ distinct numbers. We choose a permutation uniformly at random (i.e., each of the n! permutations of $\left \...
40 40 votes
4 answers 4 answers
6.5k
6.5k views
Misbah Ghaya asked Nov 20, 2015
6,488 views
Consider the following game. There is a list of distinct numbers. At any round, a player arbitrarily chooses two numbers $a, b$ from the list and generates a new number $...
33 33 votes
4 answers 4 answers
8.6k
8.6k views
Misbah Ghaya asked Nov 20, 2015
8,636 views
Consider the following recurrence relation:$T\left(n\right)=\begin{cases}T\left(\frac{n}{k}\right)+ T\left(\frac{3n}{4}\right)+ n & \text{if } n \geq 2 \\ 1& \text{if }...